<?php

    //$cate = getcate($link);/*print_r($cate);die;*/

    $pid = !empty($_POST['pid'])?$_POST['pid']:0;

    $cate=array();

    $sql = "select * from `cate` where `pid` = $pid";
    $result = mysqli_query($link,$sql);

    while ($arr = mysqli_fetch_assoc($result)) {

        $cate[] = $arr;

    }

    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {

        print_r(json_encode($cate));die;
    }
?>